<template>
<div class="gradient-item box-shadow_2">
    <div class="top">
        <div 
            class="top" 
            @click="toPath"
            :style="itemData.gradient">
            <div class="copy">
                <Copy
                    title="CSS"
                    :content="itemData.gradient">
                </Copy>
            </div>
        </div>
    </div>
    <div class="title">
        {{itemData.name}}
    </div>
    <div class="color-list">
        <ColorList
            :colorList="itemData.gradient">
        </ColorList>
    </div>
    <div class="bottom">
        <div class="left">
            <Like
                type="gradient"
                :dataInfo="itemData"
                :number="itemData.like">
            </Like>
        </div>
        <Date
            :date="itemData.init_date">
        </Date>
    </div>
</div>
</template>

<script>
//渐变色展示组件
import Like from '@/components/other/Like';
import Date from '@/components/other/Date';
import Copy from '@/components/other/Copy';
import ColorList from '@/components/other/ColorList';
export default {
    components: {
        Like,
        Date,
        ColorList,
        Copy,
    },
    props:{
        itemData:{ //对象数据
            type:Object,
            default:()=>{
                return {};
            },
        },
    },
    methods:{
        toPath(){
            this.$router.push({
                name:'Gradient',
                params:{
                    id:this.itemData.id,
                },
            }).catch(() => {return;});
        },
    },
}
</script>
<style lang="scss" scoped>
.gradient-item{
    width: 100%;
    border: none;
    background-color: white;
    padding: 10px;
    box-sizing: border-box;
    border-radius: 5px;
    text-align: center;
    >.top{
        border-radius: 5px;
        overflow: hidden;
        >.top{
            position: relative;
            width: 100%;
            height: 190px;
            margin: 0 auto;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.2s;
            >.copy{
                width: fit-content;
                position: absolute;
                bottom: 5px;
                left: 5px;
                opacity: 0;
                transition: all 0.2s;
                /deep/.Copy{
                    border-radius: 3px;
                    font-size: 1.4rem;
                }
            }
            &:hover{
                //width: 150px;
                margin: 0 auto;
                //border-radius: 50%;
                >.copy{
                    opacity: 1;
                }
            }
        }
    }
    >.title{
        font-size: 1.1rem;
        line-height: 1.1rem;
        font-weight: bold;
        margin-top: 10px;
        display:none;
    }
    >.color-list{
        background-color: #ffffff;
    }
    >.bottom{
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-top: 10px;
        >.left{
            margin-right: 10px;
        }
    }
}
</style>

